package com.hzjiteng.newsbymvp.news.presenter;

import com.hzjiteng.newsbymvp.bean.NewsDetailBean;
import com.hzjiteng.newsbymvp.news.model.NewsModel;
import com.hzjiteng.newsbymvp.news.model.NewsModelImpl;
import com.hzjiteng.newsbymvp.news.views.NewsDetailView;

/**
 * @author Administrator
 * @Email:lijiayan_mail@163.com
 * @created_time 2016/07/29 16:33
 */
public class NewsDetailPresenerImpl implements NewsDetailPresener, NewsModelImpl.OnLoadNewsDetailListener {

    private NewsDetailView newsDetailView;
    private NewsModel newsModel;


    public NewsDetailPresenerImpl( NewsDetailView newsDetailView) {
        this.newsDetailView = newsDetailView;
        newsModel = new NewsModelImpl();
    }

    @Override
    public void loadNewsDetail(String docId) {
        newsDetailView.showProgress();
        newsModel.loadNewsDetail(docId, this);
    }

    @Override
    public void onSuccess(NewsDetailBean detailBean) {
        if (detailBean != null)
            newsDetailView.showNewsDetailContent(detailBean.getBody());
        newsDetailView.hideProgress();

    }

    @Override
    public void onFailure(Exception e, String msg) {
        newsDetailView.hideProgress();
    }
}
